package com.project.chat.pojo;

import lombok.Data;

@Data
public class Response<T> {

    int code;
    String status;
    T data;

    public static <T> Response<T> success(T data){
        return new Response<T>(200, "success", data);
    }

    public static <T> Response<T> fail(){
        return new Response<T>(505, "error", null);
    }

    public static <T> Response<T> noFound(){
        return new Response<T>(400, "noFound", null);
    }

    public static <T> Response<T> checkNull(T data){
        if(data == null) return noFound();
        else return success(data);
    }

    public Response(int code, String status, T data){
        this.code = code;
        this.status = status;
        this.data = data;
    }
}
